<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
  <%@ page import="java.util.List,cx.cx.pojo.Car" %>
<!DOCTYPE html ">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>首页</title>

<link rel="stylesheet" href="css/bootstrap.css"/>
<script src="js/jquery-3.4.1.js" type="text/javascript"></script>
<script src="js/bootstrap.js" type="text/javascript"></script>


<style>
input:link{
color:#FF0000;
}
input:visited{
color:#00FF00;
}

input:hover{
color:#0000FF;
}

input:active{
color:yellow;
}


</style>

</head>
<body>

<form class="form-horizontal" action="Query" method="post">
					<div class="container">
       				 	<input style="width:375px" type="text" id="searchstr" placeholder="请输入车名" name="searchstr1" class="textbox " >&nbsp;&nbsp;&nbsp;&nbsp;<button type="submit" class="btn btn-primary" >搜索</button>
					</div>
				</form>

<%
List<Car> listCar = (List<Car>)session.getAttribute("list");
%>
<%-- container 容器 --%>
<div class="container">
<table class="table table-bordered">
   <tr class="success">
   <div class="row">
      <th class="col-sm-4">车名</th>
      <th class="col-sm-1">上传时间</th>
      <th class="col-sm-1">里程</th>
      <th class="col-sm-2">排量</th>
      <th class="col-sm-1">变速箱</th>
      <th class="col-sm-1">价格</th>
      <th class="col-sm-2">操作</th>
     </div>
   </tr>
   
   <% for(int i = 0; i < listCar.size(); i++){ %>
   <tr class="success">
   <td><%=listCar.get(i).getCarName()%></td>
   <td><%=listCar.get(i).getCarLoadtime()%></td>
   <td><%=listCar.get(i).getMileage()%></td>
   <td><%=listCar.get(i).getVolume()%></td>
   <td><%=listCar.get(i).getGearbox()%></td>
   <td><%=listCar.get(i).getPrice()%></td>
   <td><button type="button" class="btn btn-primary" onclick="details(<%=listCar.get(i).getId()%>)">修改</button>
   <button type="button" class="btn btn-primary" style="margin-left:8px" onclick="deleteJobDetail(<%=listCar.get(i).getId()%>)">删除</button>
   </td>
   </tr>
   <%} %>
   
</table>
</div>

<script>
// id接收传递的参数
function details(id){
	//alert(id)  get方式传参 url地址?name=value  url地址?name1=value1&name2=value2
	location.href="http://localhost:8080/car/Details?id=" + id
}


function del(id){
	location.href="http://localhost:8080/car/DelServlet?id=" + id
			
}


function deleteJobDetail(id){

	     if(window.confirm('你确定要删除吗')){
               //alert(11)
	         location.href="http://localhost:8080/car/DelServlet?id=" + id

	           return true;

	      }else{

	          return false;
	      }
	  }




</script>


</body>
</html>